namespace ne   {


    export abstract class BaseHandler {
        private _fmtstr: string = "";   //格式化输出
        private _startime: number;      //log开始时间
        private _gettime: Function;     //log开始时间

        constructor(startime?: number, gettime?: Function) {
            this._startime = startime;
            if (startime) {
                this._gettime = typeof (gettime) == "function" ? gettime : Date.now;
                this._startime = this._gettime() ? 0 : startime;

            }
        }

        /**
         * 设置输出的格式(会显示在输出的开头)
         * 
         * @param {string} fmtstr 
         * @memberof BaseHandler
         */
        public setFmter(fmtstr: string) {
            this._fmtstr = fmtstr;
        }

        public emit(nlv: ELOGLEVEL, sfmt: string, ...sout) {
        }

        private flush() { }

        protected getString(nlv: ELOGLEVEL, sfmt: string) {
            if (this._startime) {
                sfmt = "[%d]".format(this._gettime() - this._startime) + sfmt;
            }
            sfmt = "%s[%s]%s".format(this._fmtstr, ELOGLEVEL[nlv], sfmt);
            return sfmt;
        }

    }
}